<template>
	<div>
		<Banner :bannerlist='bannerList' :propbanner_imglist='banner_imglist'></Banner>
		<Icons></Icons>
		<Slide></Slide>
		<News :propnews='HomeData'></News>
		<Swiper2 :propswiper2='HomeData'></Swiper2>
		<Spike :propspikeList='HomeData' :propnewsList='newsList' :prophotList='hotList'></Spike>
		<Category :propcategory='HomeData'></Category>
		<WaterfallFlow></WaterfallFlow>
		<BottomNav topage=1></BottomNav>
	</div>
</template>

<script>
import Banner from './pages/Banner';
import Icons from './pages/Icons';
import Slide from './pages/Slide';
import News from './pages/News';
import Swiper2 from './pages/Swiper2';
import Spike from './pages/Spike';
import Category from './pages/Category';
//瀑布流
import WaterfallFlow from './pages/WaterfallFlow';

// 引入公共子组件——底部
import BottomNav from '../default/BottomNav';

import {mapState} from 'vuex';
export default {
	name:'Home',
	components:{
		Banner,
		Icons,
		Slide,
		News,
		Swiper2,
		Spike,
		Category,
		WaterfallFlow,
		BottomNav
	},
	data(){
		return {
			HomeData:[],
			bannerList:[],
			banner_imglist:[],
			newsList:[],
			hotList:[],
		}
	},
	created() {
		let url = '/api/dataHome.json';
		let that = this;
		this.axios.get(url).then((res)=>{
			that.bannerList = res.data.BannerVueList;
			that.banner_imglist = res.data.Bannerimglist;
			that.newsList = res.data.newsList;
			that.hotList = res.data.hotList;
			
			this.HomeData = res.data.Homemsg[0];
			res.data.Homemsg.forEach((item,index)=>{
				if(item.city == this.cityName){
					this.HomeData = res.data.Homemsg[index];
				}
			})
			
		}).catch((err)=>{
			console.log(err);
		})
		
	},
	computed: {
		...mapState(['cityName'])
	},
}
</script>

<style scoped>
	.iconfont {
	  font-family: "iconfont" !important;
	  font-size: 26px;
	  font-style: normal;
	  -webkit-font-smoothing: antialiased;
	  -moz-osx-font-smoothing: grayscale;
	}
</style>
